unit UsuarioPerfilRecordFr;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, DBCtrls, ActnList, Buttons, DBGrids, ExtCtrls,
  MainRecordFr;

type

  { TUsuarioPerfilRecordFrame }

  TUsuarioPerfilRecordFrame = class(TMainRecordFrame)
    InserirPerfilAction: TBitBtn;
    ExcluirPerfilAction: TBitBtn;
    DBLookupComboBox1: TDBLookupComboBox;
    GroupBox3: TGroupBox;
    Label4: TLabel;
    DBGrid1: TDBGrid;
    GroupBox2: TGroupBox;
    SalvarPerfilAction: TAction;
    CancelarPerfilAction: TAction;
    BitBtn1: TBitBtn;
    IDUsuarioDBEdit: TDBEdit;
    IDPessoaDBEdit: TDBEdit;
    nome_pessoa: TDBEdit;
    DBEdit4: TDBEdit;
    AtivoDBRadio: TDBRadioGroup;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure BitBtn1Click(Sender: TObject);
    procedure IDPessoaDBEditChange(Sender: TObject);
    procedure InserirPerfilActionClick(Sender: TObject);
    procedure ExcluirPerfilActionClick(Sender: TObject);
    procedure ControlaBotoes(); override;

  private
    { private declarations }
  public
    { public declarations }
  end;

implementation

uses
  Initializator, MainFr, UsuarioPerfilDM, MainDM;

{ TUsuarioPerfilRecordFrame }

procedure TUsuarioPerfilRecordFrame.ControlaBotoes;
begin
  inherited ControlaBotoes;
  InserirPerfilAction.Enabled := SalvarAction.Enabled;
  ExcluirPerfilAction.Enabled := SalvarAction.Enabled;
end;

procedure TUsuarioPerfilRecordFrame.BitBtn1Click(Sender: TObject);
begin
  TheControl.ShowForeignFrame(TMainFrame(UsuarioSearchFrame));
end;

procedure TUsuarioPerfilRecordFrame.IDPessoaDBEditChange(Sender: TObject);
begin
  if (UsuarioPerfilData.DataSetState() in [mdsEditing, mdsInserting]) then begin
    UsuarioPerfilData.BuscaPerfil(IDUsuarioDBEdit.Text);
  end;
end;

procedure TUsuarioPerfilRecordFrame.InserirPerfilActionClick(Sender: TObject);
begin
  if IDUsuarioDBEdit.Text <> '' then begin
    UsuarioPerfilData.InserePerfil();
    UsuarioPerfilData.UPerfilAuxZQuery.Refresh();
    ControlaBotoes();
  end;
end;

procedure TUsuarioPerfilRecordFrame.ExcluirPerfilActionClick(Sender: TObject);
begin
  if IDUsuarioDBEdit.Text <> '' then begin
    UsuarioPerfilData.RemovePerfil();
  end;
end;

initialization
  {$I usuarioperfilrecordfr.lrs}

end.
